package com.mh.www.mh_frame.view.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.mh.www.mh_frame.R;
import com.mh.www.mh_frame.model.bean.StandardBean;
import com.mh.www.mh_frame.presenter.iview.StandardView;
import com.mh.www.mh_frame.presenter.present.StandardPresent;
import com.mh.www.mh_frame.presenter.present.impl.StandardPresentImpl;
import com.mh.www.mh_frame.util.ToastUtil;
import com.mh.www.mh_frame.view.activity.base.BaseActivity;
import com.mh.www.mh_frame.view.adapter.StandardAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class StandardActivity extends BaseActivity implements StandardView {
    @BindView(R.id.ry_standard)
    RecyclerView mRyStandard;
    private StandardPresent mStandardPresent;
    private List<StandardBean.DataBean> mBeanList;
    private StandardAdapter mStandardAdapter;
    @Override
    protected void setContentLayout() {
        setContentView(R.layout.activity_standard);
    }

    @Override
    protected void initView() {
        mStandardPresent = new StandardPresentImpl();
        mStandardPresent.attachView(this);
        mStandardPresent.getStandList("","1","3","5894630b-dffc-4e93-bfe5-5e923252fbd6");
        mRyStandard.setLayoutManager(new LinearLayoutManager(this));
    }

    @Override
    protected void obtainData() {

    }

    @Override
    protected void initEvent() {

    }

    @Override
    public void setData(StandardBean bean) {
        mBeanList = new ArrayList<>();
        for (StandardBean.DataBean dataBean : bean.getData()) {
            mBeanList.add(dataBean);
        }
        mRyStandard.setAdapter(mStandardAdapter = new StandardAdapter(mBeanList));
        mStandardAdapter.notifyDataSetChanged();
        mStandardAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                ToastUtil.showShortToast(""+position);
            }
        });
    }

    @Override
    public void showProgress() {

    }

    @Override
    public void hideProgress() {

    }

    @Override
    public void showMsg(String message) {

    }

}
